package com.sojson.config.mybatis.interceptor;

import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;

/**
 * Mybatis拦截器
 * 
 * @author liu
 * @date 2021-12-20
 */
@Configuration
public class MybatisInterceptor {

    /**
     * 添加多个拦截器
     * 
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(List<InnerInterceptor> interceptors) {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        for (InnerInterceptor innerInterceptor : interceptors) {
            interceptor.addInnerInterceptor(innerInterceptor);
        }

        return interceptor;
    }

}